<?php

namespace mpend\modules\app\models;

use Yii;
use common\helpers\ArrayHelper;
use common\logics\PositionLogic;
use common\models\feedback\Feedback;
use common\models\help\Help;
use common\models\help\HelpCategory;
use common\helpers\Url;
use common\models\cso\CsoUser;

/**
 * 客服中心首页信息
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class CustomerServiceSearch extends CsoUser {

    /**
     * 保存意见内容
     *
     * @param int $uid
     * @return mixed
     * @throws \yii\base\InvalidConfigException
     */
    public function connect($uid = 0) {
        $servers = static::find()->andWhere([
            '!=', 'qrcode', '',
        ])->all();
        $nums = count($servers);
        if ($nums < 1) {
            return static::defaultServer();
        }
        if ($uid) {
            $no = $uid % $nums;
            $server = ArrayHelper::getValue($servers, $no);
            if (!$server) {
                return static::defaultServer();
            }
            return $server;
        }
        return static::defaultServer();
    }

}
